/*
 * Serum
 *
 * @license      GNU Lesser General Public Licence see LICENCE-LGPL file or http://www.gnu.org/licenses/lgpl.html
 */

Ext.namespace('Serum.Form.Module.Languages', 'Serum.Grid.Module.Languages');

Serum.Module.Languages = Ext.extend(Serum.Module.Base, {

    formClass: function() {
        switch (Serum.Selector.get().action) {
			case 'add':
                return 'Serum.Form.Module.Languages.Add';
			case 'edit':
                return 'Serum.Form.Module.Languages.Edit';
		}

        return Serum.Module.Languages.superclass.formClass.call(this);
    },

    onProcessSuccess: function(result) {
        window.location.reload();
    }
});

Serum.Form.Module.Languages.Add = Ext.extend(Serum.Form.Module.Edit, {

    /**
     * Called after a successful form submit.
     *
     * @param   {Ext.form.BasicForm}    form        Submitted form
     * @param   {Object}                action      Returned value
     */
    onSuccess: function(form, action) {
        window.location.reload();
    },

    fieldsList: function() {
        return {
            'default': [{
                'name':             {},
                'code':             {},
                'DbCountry':        {}
            }]
        };
    }
});

Serum.Form.Module.Languages.Edit = Ext.extend(Serum.Form.Module.Edit, {

    /**
     * Called after a successful form submit.
     *
     * @param   {Ext.form.BasicForm}    form        Submitted form
     * @param   {Object}                action      Returned value
     */
    onSuccess: function(form, action) {
        window.location.reload();
    },

    fieldsList: function() {
        return {
            'default': [{
                'name':             {},
                'code':             {},
                'DbCountry':        {}
            }],

            'activate': [{
                'displayInFront':   {},
                'displayInBack':    {},
                'parentRoot':       {
                                      name:     'parentRoot',
                                      xtype:    'hidden',
                                      value:    Serum.Selector.get().getParams['parentRoot']
                                    }
            }]
        };
    }
});
